<?php
// This is for getting the language from the url and setting up the translator to use the necessary language files
// Should be included in the init of controllers
// sets the 'text' view variable to the array of the language

// Get the language parameter
		
		$request = $this->getRequest();
		$lang = $request->getParam('lang');
		
		
		
		// Set up the translator
		Zend_Loader::loadClass('Zend_Translate');
		
		// Set up filename for translator
		$controller = $request->getParam('controller');
		
				
		// Use translate only if not index page (controller = null)
		if ($controller != null) {
			$filename = 'languages/'.$controller;
			$translate = new Zend_Translate('array', $filename.'.ro', 'ro');
			$translate->addTranslation($filename.'.hu', 'hu');
			$translate->setLocale($lang);
			
			// Get translation for current page and send it to the template
			$messages = $translate->getMessages();
			$this->view->text = $messages;
			$this->view->lang = $lang;
			
		}
		
		// Pass general view variables
		$translate = new Zend_Translate('array', 'languages/general.ro', 'ro');
		$translate->addTranslation('languages/general.hu', 'hu');
		$translate->setLocale($lang);
		$messages = $translate->getMessages();
		$this->view->general = $messages;
		
		// Set base url which contains the language id
		Zend_Loader::loadClass('Zend_Session_Namespace');
		$reg = new Zend_Session_Namespace();
		$this->view->lang_url = $reg->config->base_url.$lang."/";
?>